<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<script type="text/ecmascript" src="assets/vendor/editor.md/editormd.js"></script>

<link rel="stylesheet" href="assets/vendor/editor.md/css/editormd.css" />

<div id="editormd"><textarea style="display:none;"></textarea></div>
<script type="text/javascript">

var editor;

function updateSetting(setting, mySetting){
	// loop mySetting, Object.assign(target,s1[,s2[,...]])
	for(key in mySetting){
		val = mySetting[key]
		if(Object.prototype.toString.call(val)==="[object Object]"){
			if(typeof(setting[key])==="undefined"){
				setting[key] = val
			}
			else setting[key] = updateSetting(setting[key],val) 
		}
		else {
			setting[key] = val
		}
		
	}
	return setting
}

function createEditor(content, mySetting){
	setting = {
	        width  : "100%",            
	        height : "100%",           
	        theme : "dark",             
	        path   : "assets/vendor/editor.md/lib/",   // lib path of editor.md plug-in
	        markdown :content,
	        saveHTMLToTextarea : true, 
	        toolbarAutoFixed:false,  //always put toolbar at top
// 	        imageUpload : true,         //allow to upload images
// 	        imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],    //image extantino
// 	        imageUploadURL : "releaseNote/image/upload.do",                 //upload url
//	      toolbarIcons: function () {  // use simple mode for custom save button
//	             return editormd.toolbarModes['full']; // full, simple, mini
//	         },
	        lang : {
	            name : "en",
	            description : "Open source online Markdown editor.",
	            tocTitle    : "Table of Contents",
	            toolbar : {
	                undo             : "Undo(Ctrl+Z)",
	                redo             : "Redo(Ctrl+Y)",
	                bold             : "Bold",
	                del              : "Strikethrough",
	                italic           : "Italic",
	                quote            : "Block quote",
	                ucwords          : "Words first letter convert to uppercase",
	                uppercase        : "Selection text convert to uppercase",
	                lowercase        : "Selection text convert to lowercase",
	                h1               : "Heading 1",
	                h2               : "Heading 2",
	                h3               : "Heading 3",
	                h4               : "Heading 4",
	                h5               : "Heading 5",
	                h6               : "Heading 6",
	                "list-ul"        : "Unordered list",
	                "list-ol"        : "Ordered list",
	                hr               : "Horizontal rule",
	                link             : "Link",
	                "reference-link" : "Reference link",
	                image            : "Image",
	                code             : "Code inline",
	                "preformatted-text" : "Preformatted text / Code block (Tab indent)",
	                "code-block"     : "Code block (Multi-languages)",
	                table            : "Tables",
	                datetime         : "Datetime",
	                emoji            : "Emoji",
	                "html-entities"  : "HTML Entities",
	                pagebreak        : "Page break",
	                watch            : "Unwatch",
	                unwatch          : "Watch",
	                preview          : "HTML Preview (Press Shift + ESC exit)",
	                fullscreen       : "Fullscreen (Press ESC exit)",
	                clear            : "Clear",
	                search           : "Search",
	                help             : "Help",
	                info             : "About ",
	                "save"           : "Save",
	            },
	            buttons : {
	                enter  : "Enter",
	                cancel : "Cancel",
	                close  : "Close"
	            },
	            dialog : {
	                link : {
	                    title    : "Link",
	                    url      : "Address",
	                    urlTitle : "Title",
	                    urlEmpty : "Error: Please fill in the link address."
	                },
	                referenceLink : {
	                    title    : "Reference link",
	                    name     : "Name",
	                    url      : "Address",
	                    urlId    : "ID",
	                    urlTitle : "Title",
	                    nameEmpty: "Error: Reference name can't be empty.",
	                    idEmpty  : "Error: Please fill in reference link id.",
	                    urlEmpty : "Error: Please fill in reference link url address."
	                },
	                image : {
	                    title    : "Image",
	                    url      : "Address",
	                    link     : "Link",
	                    alt      : "Title",
	                    uploadButton     : "Upload",
	                    imageURLEmpty    : "Error: picture url address can't be empty.",
	                    uploadFileEmpty  : "Error: upload pictures cannot be empty!",
	                    formatNotAllowed : "Error: only allows to upload pictures file, upload allowed image file format:"
	                },
	                preformattedText : {
	                    title             : "Preformatted text / Codes", 
	                    emptyAlert        : "Error: Please fill in the Preformatted text or content of the codes.",
	                    placeholder       : "coding now...."
	                },
	                codeBlock : {
	                    title             : "Code block",         
	                    selectLabel       : "Languages: ",
	                    selectDefaultText : "select a code language...",
	                    otherLanguage     : "Other languages",
	                    unselectedLanguageAlert : "Error: Please select the code language.",
	                    codeEmptyAlert    : "Error: Please fill in the code content.",
	                    placeholder       : "coding now...."
	                },
	                htmlEntities : {
	                    title : "HTML Entities"
	                },
	                help : {
	                    title : "Help"
	                }
	            }
	        },
	      }
	setting = updateSetting(setting,mySetting);
    editor = editormd("editormd", setting);
}

</script>